VSTO  Extract the name of the "MAILTO" section from an email already in the send box.

Hi !

       I make in VSTO C# an plugin to save selected email with a custom name.

Ex: When I take an email from the inbox I save the SenderName from the mailitem.

When I take an email from the sendbox  I would like save the name from the MAILTO of the mailitem.

I have try to use the ReceivedByName option of the mailitem, but It stay empty...

How I can extract the name of the sender MAILTO from an already send email to put this name in a string value ?

Actually I use this code to extract the sendername when I work with the inbox and sendbox folder email:

                   

if(selObject isOutlook.MailItem)

{

               

ObjectselObject = Application.ActiveExplorer().Selection[compteur_selection];

        

                        mailItem = (selObject asOutlook.MailItem);

                        sujet = mailItem.Subject;

                        sujet = sujet.Replace(":", " ");

                        sujet = sujet.Replace("/", " ");

                      // all this var are string format

                        date_heure = mailItem.ReceivedTime.ToShortDateString();//work greet !

                        expediteur = mailItem.SenderName; // Work greet!

                        destinataire_ea = mailItem.ReceivedByName; // this stay empty...

}

SaveFileDialog

save = newSaveFileDialog();

                        save.FileName = date_heure.ToString() +

"_Nom du projet_EA_"+ destinataire + "_"+ sujet + "_V_"+ initiale_expediteur;

                        save.DefaultExt = ".msg";

                        save.Filter = "Format de message Outlook|*.msg";

                        save.ShowDialog();

                        mailItem.SaveAs(@save.FileName, Outlook.OlSaveAsType.olMSG);

thank's for your help on this case !

emarck

July 15th, 2013 6:30pm

Programming/Code related questions should really be posed in one of the following forums:

Outlook for Developers
http://social.msdn.microsoft.com/Forums/en-US/outlookdev
Microsoft Office Programming
http://answers.microsoft.com/en-us/office/forum/customize?page=1&tab=all&tm=1361680524815

Tony Chen
TechNet Community Support


Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2013 5:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics